package com.hanhai.zrb.mobile.controller;

import java.util.Date;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.hanhai.common.web.controller.BaseController;
import com.hanhai.zrb.api.biz.service.IntentionMessageService;
import com.hanhai.zrb.mobile.result.BaseApiResult;
import com.hanhai.zrb.mobile.util.FrontLoginUtil;
import com.hanhai.zrb.model.common.BaseUser;
import com.hanhai.zrb.model.intention.IntentionMessage;

@Controller
@RequestMapping("/intentionMessage")
@RestController
public class IntentionMessageApiController extends BaseController {

	@Resource
	private IntentionMessageService intentionMessageService;

	@RequestMapping("/add")
	public BaseApiResult add(IntentionMessage intentionMessage) {
		BaseApiResult result = new BaseApiResult();
		BaseUser baseUser = FrontLoginUtil.getCurrentUser();
		intentionMessage.setCreateTime(new Date());
		intentionMessage.setUserId(baseUser.getUid());
		intentionMessage.setStatus(0);
		if (intentionMessageService.appLeaveMessage(intentionMessage)) {
			result.setMsg("留言成功!");
		} else {
			result.setRes(0);
			result.setMsg("留言失败!");
		}
		return result;
	}
}
